/*  公共方法库   */
// sourceUrl=common/common.js

/**
 * 计算年龄
 * @param beginStr
 * @param endStr
 * @returns
 */
function getAge(beginStr, endStr) {
	var reg = new RegExp(
			/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})(\s)(\d{1,2})(:)(\d{1,2})(:{0,1})(\d{0,2})$/);
	var beginArr = beginStr.match(reg);
	var endArr = endStr.match(reg);
	var days = 0;
	var month = 0;
	var year = 0;
	days = endArr[4] - beginArr[4];
	if (days < 0) {
		month = -1;
		days = 30 + days;
	}
	month = month + (endArr[3] - beginArr[3]);
	if (month < 0) {
		year = -1;
		month = 12 + month;
	}
	year = year + (endArr[1] - beginArr[1]);
	var yearString = year > 0 ? year + "岁" : "";
	var mnthString = month > 0 ? month + "月" : "";
	var dayString = days > 0 ? days + "天" : "";
	/*
	 * 1 如果岁 大于等于1 那么年龄取 几岁 2 如果 岁等于0 但是月大于1 那么如果天等于0 天小于3天 取小时 例如出生2天 就取 48小时
	 */
	var result = "";
	if (year >= 1) {
		result = yearString + mnthString;
	} else {
		if (month >= 1) {
			result = days > 0 ? mnthString + dayString : mnthString;
		} else {
			var begDate = new Date(beginArr[1], beginArr[3] - 1, beginArr[4],
					beginArr[6], beginArr[8], beginArr[10]);
			var endDate = new Date(endArr[1], endArr[3] - 1, endArr[4],
					endArr[6], endArr[8], endArr[10]);
			var between = (endDate.getTime() - begDate.getTime()) / 1000;
			days = Math.floor(between / (24 * 3600));
			var hours = Math.floor(between / 3600 - (days * 24));
			var dayString = days > 0 ? days + "天" : "";
			result = days >= 3 ? dayString : days * 24 + hours + "小时";
		}
	}
	return result;
}

/**
 * 原形对象DocsAssReportRecVo 主表
 * @returns
 */
function DocsAssReportRecVo(){
	
}
// 添加原型属性
DocsAssReportRecVo.prototype.reportId=null;
DocsAssReportRecVo.prototype.patientId=null;
DocsAssReportRecVo.prototype.visitId=null;
DocsAssReportRecVo.prototype.reportDate=null;
DocsAssReportRecVo.prototype.timePoint=null;
DocsAssReportRecVo.prototype.themeCode=null;
DocsAssReportRecVo.prototype.remark=null;
DocsAssReportRecVo.prototype.createTime=null;
DocsAssReportRecVo.prototype.creator=null;
DocsAssReportRecVo.prototype.creatorUnit=null;
DocsAssReportRecVo.prototype.enableValue=null;
DocsAssReportRecVo.prototype.details=null;

/**
 * 原形对象DocsAssReportDetailVo 明细表
 * @returns
 */
function DocsAssReportDetailVo(){
	
}
DocsAssReportDetailVo.prototype.recId=null;
DocsAssReportDetailVo.prototype.itemName=null;
DocsAssReportDetailVo.prototype.itemValue=null;
DocsAssReportDetailVo.prototype.creator=null;
DocsAssReportDetailVo.prototype.creatorUnit=null;
DocsAssReportDetailVo.prototype.createTime=null;
DocsAssReportDetailVo.prototype.updater=null;
DocsAssReportDetailVo.prototype.updateTime=null;
DocsAssReportDetailVo.prototype.updaterUnit=null;
DocsAssReportDetailVo.prototype.enableValue=null;

/**
 * 收集id控件的带有data-tag属性的控件
 * @param ID
 * @returns
 */
function CollectControls(ID){
	var controlArray = new Array();
	var inputs = $('#' + ID + ' .row input');
	for(var i=0;i<inputs.length;i++){
		if($(inputs[i]).attr('data-tag')){
			var obj = {
				type : 	$(inputs[i]).attr('type'),
				tag : $(inputs[i]).attr('data-tag')
			};
			controlArray.push(obj);
		}
	}
	return controlArray;
}
















